/**
 * jquery.fn 拓展
 * 调用方式：$().xxx
 */
(function($){
	$.fn.extend({
		/**
		 * 调用接口查询缓存中的字典表数据，并用于选择框展示
		 * @param fatherCode 父级code
		 * @param options select2其他初始化参数
		 */
		hcSelect2Init: function(fatherCode, selectOptions, ajaxOptions) {
			var that = this;
			$.hcPostAjax({
				async: !ajaxOptions?undefined:ajaxOptions.async,
				url: basePath + "/datadict/getByFatherCode",
				data: {fatherCode: fatherCode},
				success: function(data) {
					var selectData = [];
					$.each(data, function(i) {
						selectData.push({id: this.codeValue, text: this.name});
					})
					var tempOptions = {data: selectData};
					$.extend(tempOptions, selectOptions);
					that.select2(tempOptions);
				}
			})
		}
	});
 
})(window.jQuery);